<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
  <!--  <form action="../userlogin.action" method="post">-->  
        <input type="text" name="user.username" placeholder="输入用户名" class="username"/>  
        <br/>  
        <input type="password" name="user.password" placeholder="输入密码"  class="password"/>  
        <br />  
        <input type="submit" value="登录" onclick="submit()">  
        <input type="reset" value="重置">  
    <!--  </form> -->
</body>
<script type="text/javascript" src="../JS/jquery.1.9.1.js"></script>
<script type="text/javascript">
    function submit(){
    	var userName = $(".username").val();
    	var passWord = $(".password").val();
    	if(userName == ""||passWord == ""){
    		alert("不能为空");
    		return false;
    	}
    	$.ajax({
    	   type:"post",
    	   url :"../userlogin.action",
    	   data:{
    		   username:userName,
    	       password:passWord,		   
    	   },
    	   dataType:"json",
    	   success:function(data){
    		   alert(123);
    		    if(data=="成功"){
    		    	 window.location.href="mainPage.jsp";
    		    }
    	   },
    	   error:function(){
    		   alert("失败");
    	   }
    	});    	
    }
</script>
</html>